/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package application;

import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 *
 * @author Hui
 */
public class Persons {

    private String image;
    private String name;
    private String password;
    private String status;
    private ArrayList<Status> sts = new ArrayList<Status>();
    private ArrayList<Status> friendsts = new ArrayList<Status>();
    private String friends;
    private ArrayList<String> fr = new ArrayList<String>();
  //  private ArrayList<>

    public Persons(String name, String password) {
        image = "img/user.jpg";
        this.name = name;
        this.password = password;
    }

    public Persons(String name, String password, String image) {
        this.image = image;
        this.name = name;
        this.password = password;
    }
    public void setFriendsts(ArrayList<Status> st){
        this.friendsts = st;
    }
    public void addStatus(long time,String info){
        sts.add(new Status(time,info));
    }
    public ArrayList<Status> getStatusList(){
        return sts;
    }

    public String getImage() {
        return image;
    }

    public String getName() {
        return name;
    }

    public String getPassword() {
        return password;
    }

    public String getFriends() {
        return friends;
    }

    public void SetFriendlist(ArrayList<String> a) {
        this.fr = a;
    }

    public ArrayList<String> getFriendList() {
        return this.fr;
    }

    public void friendsToArray(String a) {
        StringTokenizer st = new StringTokenizer(a, ";");
        while (st.hasMoreTokens()) {
            fr.add(st.nextToken());
        }
    }

    public void setPassword(String psw) {
        this.password = psw;
    }

    public void addFriend(String name) {
        this.getFriendList().add(name);
    }

    public String arrayTofriends() {
        StringBuilder sb = new StringBuilder();
        if (!fr.equals(null)) {
            for (int i = 0; i < this.fr.size(); i++) {
                sb.append(fr.get(i) + ";");
            }
            return sb.toString();
        } else {
            return "";
        }
    }
    public void setSelfStatus(String info){
        StringTokenizer st = new StringTokenizer(info,"|");
        while(st.hasMoreTokens()){
             StringTokenizer st2 = new StringTokenizer(st.nextToken(),"//");
             sts.add(new Status(Long.parseLong(st2.nextToken()),st2.nextToken()));
        }
    }
    public void getSelfStatus(){

    }
}
